package com.briup.ch11;

import java.io.*;
import java.util.Arrays;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/15
 * @Description:
 */
public class Test7 {
    public static void main(String[] args) throws IOException {
        File file=new File("test.txt");
        System.out.println(file.createNewFile());
        System.out.println(file.exists());
        System.out.println(file.length());

        try {
            InputStream is=new FileInputStream("test.txt");
            System.out.println(is.read());
            char c=(char)is.read();
            System.out.println(c);
            System.out.println(is.read());
            System.out.println(is.read());
            System.out.println(is.read());
            System.out.println(is.read());
            System.out.println(is.read());
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        char[] chars=new char[20];
        int i=0;
        InputStream is=new FileInputStream("test.txt");
        while(is.available()>0){
            int n=is.read();
            chars[i]=(char)n;
            i++;
        }
        is.close();
        System.out.println(Arrays.toString(chars));
    }
}
